<template>
  <div class="PopularSinger">
    <div class="title" @click="JumpToHomePage">
      <span class="iconfont icon-xiangzuo"></span>热门歌手
    </div>
    <van-tabs v-model="activeName">
      <van-tab title="男歌手" name="a">
        <div class="content">
          <div class="swiper-container swiper-container-02">
            <div class="swiper-wrapper">
              <div
                class="swiper-slide item"
                v-for="(item, index) in ArtistListMale"
                :key="index"
              >
                <router-link
                  class="img"
                  :to="'/recommend/singerID?id=' + item.id"
                >
                  <img :src="item.img1v1Url" />
                </router-link>
                <p>{{ item.name }}</p>
              </div>
            </div>
            <div class="swiper-pagination swiper-pagination-02"></div>
          </div>
        </div>
      </van-tab>
      <van-tab title="女歌手" name="b">
        <div class="content">
          <div class="swiper-container swiper-container-02">
            <div class="swiper-wrapper">
              <div
                class="swiper-slide item"
                v-for="(item, index) in ArtistListFemale"
                :key="index"
              >
                <router-link
                  class="img"
                  :to="'/recommend/singerID?id=' + item.id"
                >
                  <img :src="item.img1v1Url" />
                </router-link>
                <p>{{ item.name }}</p>
              </div>
            </div>
            <div class="swiper-pagination swiper-pagination-02"></div>
          </div>
        </div>
      </van-tab>
      <van-tab title="乐队" name="c">
        <div class="content">
          <div class="swiper-container swiper-container-02">
            <div class="swiper-wrapper">
              <div
                class="swiper-slide item"
                v-for="(item, index) in ArtistListBand"
                :key="index"
              >
                <router-link
                  class="img"
                  :to="'/recommend/singerID?id=' + item.id"
                >
                  <img :src="item.img1v1Url" />
                </router-link>
                <p>{{ item.name }}</p>
              </div>
            </div>
            <div class="swiper-pagination swiper-pagination-02"></div>
          </div>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
import { getArtistList } from "../../api/ranking";
export default {
  data() {
    return {
      activeName: "a",
      ArtistListMale: null,
      ArtistListFemale: null,
      ArtistListBand: null,
    };
  },
  methods: {
    JumpToHomePage() {
      this.$router.push("/recommend");
    },
    getArtistListMale() {
      getArtistList({ type: 1, area: -1 }).then((data) => {
        this.ArtistListMale = data.artists;
      });
    },
    getArtistListFemale() {
      getArtistList({ type: 2, area: -1 }).then((data) => {
        this.ArtistListFemale = data.artists;
      });
    },
    getArtistListBand() {
      getArtistList({ type: 3, area: -1 }).then((data) => {
        this.ArtistListBand = data.artists;
      });
    },
  },
  created() {
    this.getArtistListMale();
    this.getArtistListFemale();
    this.getArtistListBand();
  },
};
</script>
<style lang="less">
.PopularSinger {
  .title {
    height: 40px;
    line-height: 40px;
    font-size: 16px;
    color: white;
    font-weight: 500;
    background-color: #d44439;
  }
  .content {
    width: 100%;
    height: 25vh;
    .swiper-wrapper {
      display: flex;
      justify-content: space-around;
      flex-wrap: wrap;
      .item {
        flex: 0 0 30%;
        position: relative;
        .img {
          min-height: 50px;
          width: 100%;
          border-radius: 8px;
          img {
            width: 100%;
            border-radius: 8px;
          }
        }
        p {
          font-size: 12px;
          color: #565658;
          line-height: 15px;
          padding: 3px;
          margin-bottom: 10px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
      }
    }
  }
}
</style>